home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Online / SpeakFreely / src / gsm / add-test / add_test.dta < prev   
Text File  |  2000-05-18  |  7KB  |  436 lines

  1. ;
  2. ; Copyright 1992 by Jutta Degener and Carsten Bormann, Technische
  3. ; Universitaet Berlin.  See the accompanying file "COPYRIGHT" for
  4. ; details.  THERE IS ABSOLUTELY NO WARRANTY FOR THIS SOFTWARE.
  5. ;
  6. ;
  7. ;    Lines starting with ' (in the first col) are echoed.
  8. ;    Lines starting with " (in the first col) are echoed to stderr.
  9. ;    Lines starting with ; or empty lines are ignored.
  10. ;
  11. ;    The part after (including) a trailing '=' is what you expect;
  12. ;    there will be output if the result is different.
  13. ;
  14. ;    -  and +  by itself mean MIN_WORD and MAX_WORD, respecitvely;
  15. ;    -- and ++ mean MIN_LONGWORLD and MAX_LONGWORD.
  16. ;
  17.  
  18. 'test the basic arithmetic operations used for the rpe-ltd filtering.
  19. '
  20. 'add ================
  21. '  basic
  22.  
  23.     add  0  0     =  0
  24.     add  7  4    = 11
  25.     add  4  6     = 10
  26.     add  1  1     =  2
  27.  
  28. '  negative operands
  29.  
  30.     add  -7  4    = -3
  31.     add   4 -6     = -2
  32.     add  -1 -3     = -4
  33.     add   7 -4    =  3
  34.     add  -4  6     =  2
  35.  
  36. '  positive overflow
  37. ; (max-word = 32767)
  38.     add  + 1    = +
  39.     add  + +    = +
  40.     add  -1 +     = 32766
  41.     add  32766 2    = +
  42.     add  1 32766      = +
  43.  
  44. '  underflow
  45. ; (min-word = 32768)
  46.  
  47.     add  - -1    = -
  48.     add  - -    = -
  49.     add  1 -    = -32767  
  50.     add  -32767 -2    = -
  51.     add  -1 -32766     = -32767
  52.     add  -32767 -1    = -
  53.     add  - +    = -1
  54.     add  + -    = -1
  55.     add  0 -    = -
  56.     add  0 +    = +
  57. '
  58.  
  59. 'L_add ================
  60. '  basic 
  61.  
  62.     L_add  0  0     =  0
  63.     L_add  7  4    = 11
  64.     L_add  4  6     = 10
  65.     L_add  1  1     =  2
  66.  
  67. '  negative operands
  68.  
  69.     L_add  -7  4    = -3
  70.     L_add   4 -6     = -2
  71.     L_add  -1 -3     = -4
  72.     L_add   7 -4    =  3
  73.     L_add  -4  6     =  2
  74.     L_add   0 -1     = -1
  75.  
  76. '  positive overflow
  77. ; (max-longword = 2147483647)
  78.     L_add  ++ 1    = ++
  79.     L_add  ++ ++    = ++
  80.     L_add  -1 ++     = 2147483646
  81.     L_add  2147483646 2 = ++
  82.     L_add  1 2147483645 = 2147483646
  83.  
  84. '  underflow
  85. ; (min-longword = -2147483648)
  86.  
  87.     L_add  -- -1    = --
  88.     L_add  -- --    = --
  89.     L_add  1 --    = -2147483647
  90.     L_add  -2147483647 -2    = --
  91.     L_add  -1 -2147483646     = -2147483647
  92.     L_add  -2147483647 -1    = --
  93.     L_add  -- ++    = -1
  94.     L_add  ++ --    = -1
  95.     L_add  0 --    = --
  96.     L_add  0 ++    = ++
  97. '
  98.  
  99. 'sub ================
  100. '  basic 
  101.  
  102.     sub  0  0     =  0
  103.     sub  7  4    =  3
  104.     sub  4  6     = -2
  105.     sub  1  0     =  1
  106.  
  107. '  negative operands
  108.  
  109.     sub  -7  4    = -11
  110.     sub   4 -6     =  10
  111.     sub  -1 -3     =  2
  112.     sub   7 -4    =  11
  113.     sub  -4  6     = -10
  114.  
  115. '  positive overflow
  116. ; (max-word = 32767)
  117.     sub  1 -    = +
  118.     sub  + +    = 0
  119.     sub  + 0    = +
  120.     sub  + -1     = +
  121.     sub  + 1     = 32766
  122.     sub  1 +     = -32766 
  123.     sub  0 +      = -32767
  124.  
  125. '  underflow
  126. ; (min-word = 32768)
  127.  
  128.     sub  - -1    = -32767
  129.     sub  - 1    = -
  130.     sub  - -    = 0
  131.     sub  - +    = -
  132.     sub  + -    = +
  133.     sub  1 -    = +
  134.     sub  -1 -    = +
  135.     sub  -32767 2    = -
  136.     sub  0 -    = +
  137.  
  138. 'L_sub ================
  139. '  basic 
  140.  
  141.     L_sub  0  0     =  0
  142.     L_sub  7  4    =  3
  143.     L_sub  4  6     = -2
  144.     L_sub  1  0     =  1
  145.  
  146. '  negative operands
  147.  
  148.     L_sub  -7  4    = -11
  149.     L_sub   4 -6     =  10
  150.     L_sub  -1 -3     =  2
  151.     L_sub   7 -4    =  11
  152.     L_sub  -4  6     = -10
  153.  
  154. '  positive overflow
  155.     L_sub  1 --    = ++
  156.     L_sub  ++ ++    = 0
  157.     L_sub  ++ 0    = ++
  158.     L_sub  ++ -1     = ++
  159.     L_sub  ++ 1     =  2147483646
  160.     L_sub  1 ++     = -2147483646
  161.     L_sub  0 ++      = -2147483647
  162.  
  163. '  underflow
  164.  
  165.     L_sub  -- -1    = -2147483647
  166.     L_sub  -- 1    = --
  167.     L_sub  -- --    = 0
  168.     L_sub  -- ++    = --
  169.     L_sub  + --    = ++
  170.     L_sub  1 --    = ++
  171.     L_sub  -1 --    = ++
  172.     L_sub  -2147483647 2 = --
  173.     L_sub  0 --    = ++
  174.  
  175. '
  176. 'abs ================
  177. '  basic 
  178.  
  179.     abs       0    =   0
  180.     abs       2    =   2
  181.     abs    -459    = 459
  182.  
  183. '  overflow
  184.  
  185.     abs     +    =   +
  186.     abs     -    =   +
  187.     abs     -32767  =   +
  188.     abs      32766  = 32766
  189.     abs     -32766  = 32766
  190.  
  191. '
  192. 'mult ================
  193. ;  actually, a * b >> 15
  194.  
  195. '  basic 
  196.     mult    0  0        = 0
  197.     mult    0x100 0x100    = 2
  198.     mult    4711 0x4000    = 2355
  199.  
  200. '  negative operands
  201.     mult    -1  0        =  0
  202.  
  203.     mult    -0x100   0x100    = -2
  204.     mult     0x100  -0x100    = -2
  205.     mult    -0x100  -0x100    =  2
  206.  
  207.     mult    -4711   0x4000    = -2356
  208.     mult     4711  -0x4000    = -2356
  209.     mult    -4711  -0x4000    =  2355
  210.  
  211. '  overflow
  212.     mult    + +      = 32766
  213.     mult    + 0x4000 = 0x3fff
  214.     mult    0x4000 + = 0x3fff
  215.     mult    + 1     = 0
  216.     mult    + 2     = 1
  217.     mult    + 3     = 2
  218.  
  219. '  underflow
  220.     mult    - -      = +
  221.     mult    - +      = -32767
  222.     mult    + -      = -32767
  223.     mult    - 1     = -1
  224.     mult    - 2     = -2
  225.     mult    - 3     = -3
  226.  
  227. '
  228. 'mult_r ================
  229. ;  actually, (a * b + 16384) >> 15
  230.  
  231. '  basic 
  232.     mult_r    0  0        = 0
  233.     mult_r    0x100 0x100    = 2
  234.     mult_r    4711 0x4000    = 2356
  235.  
  236. '  negative operands
  237.     mult_r    -1  0        =  0
  238.  
  239.     mult_r    -0x100   0x100    = -2
  240.     mult_r     0x100  -0x100    = -2
  241.     mult_r    -0x100  -0x100    =  2
  242.  
  243.     mult_r    -4711   0x4000    = -2355
  244.     mult_r     4711  -0x4000    = -2355
  245.     mult_r    -4711  -0x4000    =  2356
  246.  
  247. '  overflow
  248.     mult_r    + +      = 32766
  249.     mult_r    + 32766     = 32765
  250.     mult_r    32766 +     = 32765
  251.     mult_r    + 0x4000 = 0x4000
  252.     mult_r    0x4000 + = 0x4000
  253.     mult_r    + 0x4001 = 0x4000
  254.     mult_r    0x4001 + = 0x4000
  255.     mult_r    + 2     = 2
  256.     mult_r    + 1     = 1
  257.     mult_r    1 +     = 1
  258.     mult_r    + 0     = 0
  259.     mult_r    0 +     = 0
  260.  
  261. '  underflow
  262.     mult_r    - -      = +
  263.     mult_r    - +      = -32767
  264.     mult_r    + -      = -32767
  265.     mult_r    - 1     = -1
  266.     mult_r    - 2     = -2
  267.     mult_r    - 3     = -3
  268.  
  269. '
  270. 'L_mult ================
  271. ;  actually, (a * b) << 1
  272. ;  assert (a != MIN_WORD && b != MIN_WORD)
  273.  
  274. '  basic 
  275.     L_mult    0  0    = 0
  276.     L_mult    2  3    = 12
  277.     L_mult    4711 5    = 47110
  278.  
  279. '  negative operands
  280.  
  281.     L_mult    -2  3    = -12
  282.     L_mult     2 -3    = -12
  283.     L_mult    -2 -3    =  12
  284.     L_mult -4711  5    = -47110
  285.     L_mult    4711 -5    = -47110
  286.     L_mult -4711 -5    =  47110
  287.  
  288. '  overflow
  289.     L_mult    + +      = 2147352578
  290.     L_mult    + -32767 = -2147352578
  291.     L_mult    -32767 + = -2147352578
  292.     L_mult    + 2     = 131068
  293.     L_mult    + 1     = 65534
  294.     L_mult    1 +     = 65534
  295.     L_mult    + 0     = 0
  296.     L_mult    0 +     = 0
  297.  
  298. '
  299. 'div ================
  300. ;  actually, (32767 * a) / b
  301. ;  assert (a > 0 && b >= a)
  302.  
  303. '  basic 
  304.     div    1 1        = +
  305.     div    4711 4711     = +
  306.     div    5 10        = 0x4000
  307.     div    5 20        = 0x2000
  308.     div    5 40        = 0x1000
  309.  
  310. '  overflow
  311.     div    + +         = +
  312.     div    0x4000 +    = 0x4000
  313.     div    1 +        = 1
  314.     div    1 2        = 0x4000
  315. '
  316. 'norm ================
  317.  
  318. '  positive
  319.     norm    1        = 30
  320.     norm    2        = 29
  321.     norm    3        = 29
  322.     norm    4        = 28
  323.     norm    5        = 28
  324. ; etc, etc...
  325.     norm    0x08000000    = 3
  326.     norm    0x10000000    = 2
  327.     norm    0x20000000    = 1
  328.     norm    0x20000001    = 1
  329.     norm    0x3fffffff    = 1
  330.     norm    0x40000000    = 0
  331.     norm    0x40000001    = 0
  332.     norm    0x4ffffffe    = 0
  333.     norm    ++        = 0
  334.  
  335. '  negative
  336.     norm    -1        = 31
  337.     norm    -2        = 30
  338.     norm    -3        = 29
  339.     norm    -4        = 29
  340.     norm    -5        = 28
  341. ; etc, etc...
  342.     norm    0x4fffffff    = 0
  343.     norm    --        = 0
  344. '
  345. '>> ================
  346.  
  347. '  basic 
  348.     >>    1 1        = 0
  349.     >>    4 2        = 1
  350.     >>    0x1100 5    = 0x88
  351.  
  352. '  negative operand
  353.  
  354.     >>    1 -1        = 2
  355.     >>    1 -2        = 4
  356.     >>    0x88 -5        = 0x1100
  357.  
  358. '  overflow
  359.     >>    -1 4711        = -1
  360.     >>    1  4711        = 0
  361.     >>    -4711 4711     = -1
  362.     >>    4711 4711     = 0
  363.     >>    + 1        =  16383
  364.     >>    - 1        = -16384
  365. '
  366. 'L_>> ================
  367.  
  368. '  basic 
  369.     L_>>    1 1        = 0
  370.     L_>>    4 2        = 1
  371.     L_>>    0x1100 5    = 0x88
  372.  
  373. '  negative operand
  374.  
  375.     L_>>    1 -1        = 2
  376.     L_>>    1 -2        = 4
  377.     L_>>    0x88 -5        = 0x1100
  378.  
  379. '  overflow
  380.     L_>>    -1 4711        = -1
  381.     L_>>    1  4711        = 0
  382.     L_>>    -4711 4711     = -1
  383.     L_>>    4711 4711     = 0
  384.     L_>>    ++ 1        =  1073741823
  385.     L_>>    -- 1        = -1073741824
  386.  
  387. '
  388. '<< ================
  389.  
  390. '  basic 
  391.     <<    1 1        = 2
  392.     <<    4 2        = 16
  393.     <<    0x0088 5    = 0x1100
  394.  
  395. '  negative operand
  396.  
  397.     <<    1 -1        = 0
  398.     <<    4 -2        = 1
  399.     <<    0x1100 -5    = 0x0088
  400.  
  401. '  overflow
  402.     <<    -1 4711        = 0
  403.     <<    1  4711        = 0
  404.     <<    -4711 4711     = 0
  405.     <<    4711 4711     = 0
  406.     <<    4711 -4711     = 0
  407.     <<    -4711 -4711     = -1
  408.     <<    + 1        = 0xfffe
  409.     <<    -1 1        = 0xfffe
  410.     <<    - 1        = 0
  411. '
  412. 'L_<< ================
  413.  
  414. '  basic 
  415.     L_<<    1 1        = 2
  416.     L_<<    4 2        = 16
  417.     L_<<    0x0088 5    = 0x1100
  418.  
  419. '  negative operand
  420.  
  421.     L_<<    1 -1        = 0
  422.     L_<<    4 -2        = 1
  423.     L_<<    0x1100 -5    = 0x0088
  424.  
  425. '  overflow
  426.     L_<<    -1 4711        = 0
  427.     L_<<    1  4711        = 0
  428.     L_<<    -4711 4711     = 0
  429.     L_<<    4711 4711     = 0
  430.     L_<<    4711 -4711     = 0
  431.     L_<<    -4711 -4711     = -1
  432.     L_<<    ++ 1        = -2
  433.     L_<<    -1 1        = -2
  434.     L_<<    -- 1        = 0
  435.